package day22;

import java.util.Scanner;

/**
 * 功能描述
 *
 * @author wileda
 * @date 2023/03/30  7:51
 */
public class Solution {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()){
            int n = scanner.nextInt();//怪物的数量
            int initial = scanner.nextInt();//小易的初始能力
            int[] monster = new int[n];
            for (int i = 0; i < monster.length; i++) {
                monster[i] = scanner.nextInt();
            }
            int result = countInitial(n,initial,monster);
            System.out.println(result);
        }
    }

    private static int countInitial(int n, int initial, int[] monster) {
        if(monster == null || monster.length == 0){
            return initial;
        }
        for(int i = 0; i < n; i++){
            if(initial > monster[i]){
                initial += monster[i];
            }else {
                initial += num(initial,monster[i]);
            }
        }
        return initial;
    }

    private static int num(int initial, int i) {
        int c = i % initial;
        while(c != 0){
            i = initial;
            initial = c;
            c = i % initial;
        }
        return initial;
    }
}
